package RMIServer;

import java.io.Serializable;
import java.util.*;
import Middleware.IPlayer;
import Middleware.ICard;

public class Player implements IPlayer, Serializable {
	private static final long serialVersionUID = 7464041922531483276L;
	private ArrayList<ICard> cards;
	private User user;
	private int bet;
	private String type;
	boolean my_turn;
	boolean i_am_winner;
	boolean show_my_cards;
	
	public Player(User user) {
		this.user = user;
		this.bet = 0;
		this.cards = new ArrayList<ICard>();
		this.type = "normal";
		my_turn = false;
		show_my_cards = false;
		i_am_winner = false;
	}
	
	public void clearBet() {
		bet = 0;
	}
	
	public int getBet() {
		return bet;
	}
	
	public void setBet(int bet) {
		this.bet = bet;
	}
	
	public void addCard(ICard card) {
		cards.add(card);
	}
	
	public void clearCards() {
		cards.clear();
	}
	
	public ArrayList<ICard> getCards() {
		return cards;
	}
	
	public String getType() {
		return type;
	}
	
	public void setType(String type) {
		this.type = type;
	}

	public String getUsername() {
		return user.username();
	}
	
	public IPlayer getUserClone() {
		IPlayer res = new Player(user);
		return res;
	}

	public boolean isMyTurn() {
		return my_turn;
	}

	public void setMyTurn(boolean turn) {
		my_turn = turn;
	}

	public boolean isWinner() {
		return i_am_winner;
	}

	public void setIsWinner(boolean winner) {
		i_am_winner = winner;
	}

	public void setShowCards(boolean show) {
		show_my_cards = show;
	}

	public boolean showCards() {
		return show_my_cards;
	}
	
	public double getCredit() {
		return user.interogateCredit();
	}
}
